<?php
/**
 * Netflix_User Class.
 * 
 * @author Armando Padilla, armando_padilla_81@yahoo.com
 * @package Zend_Service_Netflix
 */
class Netflix_User {

	/**
	 * User Id
	 *
	 * @var unknown_type
	 */
	public $id;
	
	/**
	 * First Name.
	 *
	 * @var unknown_type
	 */
	public $firstName;

	/**
	 * Last Name.
	 *
	 * @var unknown_type
	 */
	public $lastName;
	
	/**
	 * Can Instant Watch.
	 *
	 * @var unknown_type
	 */
	public $canInstantWatch;
	
	/**
	 * Preferred Formats
	 *
	 * @var unknown_type
	 */
	public $preferredFormats = array();
	
	/**
	 * API Ref URL.
	 *
	 * @var unknown_type
	 */
	public $queues;
	
	/**
	 * API Ref URL.
	 *
	 * @var unknown_type
	 */
	public $rentalHistory;
	
	/**
	 * API Ref URL.
	 *
	 * @var unknown_type
	 */
	public $recommendations;
	
	/**
	 * API Ref URL.
	 *
	 * @var unknown_type
	 */
	public $titleStates;
	
	/**
	 * API REF URL.
	 *
	 * @var unknown_type
	 */
	public $ratings;
	
	/**
	 * API Ref URL.
	 *
	 * @var unknown_type
	 */
	public $reviews;
	
	
	public function __construct(){}
	
/**
	 * Load the catalog data from XML.
	 *
	 * @param unknown_type $simpleXmlObject
	 */
	public function loadXML($simpleXmlObject){
		
		//Set all properties
		$this->userId 	       = (string)$simpleXmlObject->user->user_id;
		$this->firstName 	   = (string)$simpleXmlObject->user->first_name;
		$this->lastName  	   = (string)$simpleXmlObject->user->last_name;
		$this->canInstantWatch = (boolean)$simpleXmlObject->user->can_instant_watch;
		
		//Set preferred formats
		foreach($simpleXmlObject->user->preferred_formats->category as $category){
			
			$value  = (string)$elem['label'];
			
			array_push($this->preferredFormats, $value);
			
		}
		
		//Instantiate Title Objects.
		require_once "Netflix_Title.php";
		foreach($simpleXmlObject->user->link as $link){
			
			$title = (string)$link['title'];
			$href  = (string)$link['href'];
			
			//Queues
			if($title == "queues"){
				$this->queues = $href;
			}
			
			//Rental History.
			if($title == "rental history"){
				$this->rentalHistory = $href;
			}
			
			//Recommendatins
			if($title == "recommendations"){
				$this->recommendations = $href;
			}
			
			//Title States
			if($title == "title states"){
				$this->titleStates = $href;
			}
			
			//Ratings
			if($title == "ratings"){
				$this->ratings = $href;
			}
			
			//Reviews
			if($title == "reviews"){
				$this->reviews = $href;
			}
			
		}	
		
	}
	
	
}
?>